#include "Tool_PID.h"
#include "Tool_SetPara.h"
#include "Task_Move.h"
#include "Task_Shoot.h"
#include "Module_Location.h"
#include "Module_ESC.h"
#include "Tool_COMDebug.h"
#include "Module_PitchYawMotor.h"
#include "Module_ChassisMotor.h"


/**
  * @brief  打印COMDebug可调用的函数名列表
  * @param  void
  * @retval void
  */
extern FUZZYPID PitchPID,YawPID;
extern PID ChassisPID;
extern PID Move_PID202,Move_PID203;
extern PID RM2006PID;
extern u8 RM2006backflag,ShootOnce_Flag;
extern PID Encoder_Motor;

float esc_flag;

void esc_control()
{
	ESC_Toggle();
	u1_printf("ok\r\n");
}

void esc_pwm(u8 pwm1,u8 pwm2)
{
	ESC_RUN( pwm1, pwm2);
	u1_printf("pwm1: %f pwm2: %f\r\n",pwm1,pwm2);
}


void SetShoot()
{
	  RM2006PID.SetTarget(RM2006PID.Target + 131072.0f );	//发射
	  u1_printf("position: %f\r\n",RM2006PID.Current);
}

void SetPitchPid(float m_Kp, float m_Ki, float m_Kd)
{
	PitchPID.SetPIDPara(m_Kp, m_Ki,m_Kd);
//	u1_printf("p:%f\ti:%f\td:%f\r\n",m_Kp,m_Ki,m_Kd);
}

void SetYawPid(float m_NB_PB, float m_NM_PM, float m_NS_PS,
							 float m_NB_PB_kp, float m_NM_PM_kp, float m_NS_PS_kp,
							 float m_NB_PB_kd, float m_NM_PM_kd, float m_NS_PS_kd )
{
	YawPID.Set_FUZZYPID(0,0,0,0,-8000, +8000, -500, +500, -5000, +5000,0,0,0,\
									 m_NB_PB,m_NM_PM,m_NS_PS,\
									 m_NB_PB_kp,m_NM_PM_kp,m_NS_PS_kp,\
									 0.0f,0.0f,0.0f,\
									 m_NB_PB_kd,m_NM_PM_kd,m_NS_PS_kd);
//	u1_printf("ok");
}


void SetMovePID(float target)
{
	Encoder_Motor.SetTarget(target);

}


void tips(void)
{
	unsigned char i;
	for(i=0;i<dev.fnum-1;i++)
	{
//		u1_printf("%s\r\n",dev.tab[i].tips);
	}
}

//给C语言编译的函数调用的接口
struct _m_nametab nametab[]=
{	
	{(void*)SetYawPid,"SetYawPid","void SetYawPid(float m_NB_PB, float m_NM_PM, float m_NS_PS,float m_NB_PB_kp, float m_NM_PM_kp, float m_NS_PS_kp,float m_NB_PB_kd, float m_NM_PM_kd, float m_NS_PS_kd )"},
	{(void *)ESCSetPara,"ESCSetPara","ESCSetPara(float _mESC_PWM_speed,float _mESC_PWM_volate)"},
	{(void *)SetPara_DR,"SetPara_DR","SetPara_DR(float _DR_SPEED,float _PitchScale,float _YawScale,float CARFRAMEWEIGHT)"},
	{(void *)SetPara_KM,"SetPara_KM","void SetPara_KM(SPEED1,SPEED2,PITCHWEIGHT,YAWWEIGHT1,YAWWEIGHT2,CARFRAMEWEIGHT)"},
	{(void *)SetPara_Operater,"SetPara_Operater","SetPara_Operater(u8 mode)//0:P_Mid\t1:P_Up\t2:P_Down\t3:Y_Mid"},
	{(void *)ParaSetting,"ParaSetting","ParaSetting(float _pFlag)//1:Start Setting\t2:Init Para\t3:Save Para"},
	{(void*)GetParameter_User,"GetParameter_User",""},
	{(void*)SetParameter_User,"SetParameter_User",""},
	{(void*)tips,"tips",""},
	{(void *)SetMovePID,"SetMovePID","SetMovePID(float target)"},
	{(void *)SetShoot,"SetShoot","SetShoot()"},
	{(void *)esc_pwm,"esc_pwm","esc_pwm(u8 pwm1,u8 pwm2)"},
	{(void *)esc_control,"esc_control","esc_control()"}
	
	
};

struct _m_dev dev=
{
	nametab,
	sizeof(nametab)/sizeof(struct _m_nametab),//函数数量
	0,	  	//参数数量
	0,	 	//函数ID
};

